package com.baby.security.filter;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;
import java.util.logging.LogRecord;

/**
 * @author 猪猪
 * @since 2022/6/16
 */
@Component("myFilter")
public class MyFilter implements Filter{

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("服务器启动的时候执行一次");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("doFilter start");
        filterChain.doFilter(servletRequest, servletResponse);//继续执行接下来的过滤器链
        System.out.println("doFilter end");
    }

    @Override
    public void destroy() {
        System.out.println("服务器销毁的时候执行一次");
    }

}


